<?php
// +----------------------------------------------------------------------
// | najing [ 通用后台管理系统 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020 http://www.najingquan.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 救火队队长
// +----------------------------------------------------------------------

namespace app\cardeadmin\controller;

use app\common\controller\AdminController;
use app\common\model\ApiServeLog;
use app\common\model\ApiServeAmountLog;
use think\facade\View;
use think\facade\Db;

/**
 * 系统操作管理
 * Class Operation
 * @package app\admin\controller
 */
class ApiServer extends AdminController
{
    /**
     * api金额日志
     * @author 救火队队长
     */
    public function serveAmount()
    {
        if ($this->request->isAjax()) {
            $request = input('param.');
            $logModel = new ApiServeAmountLog();
            return $logModel->tableDataAdmin($request);
        }
        return  View::fetch();
    }

    /**
     * api详细日志
     * @author 救火队队长
     * @return array|mixed
     */
    public function serveLog()
    {
        if ($this->request->isAjax()) {
            $request = input('param.');
            $logModel = new ApiServeLog();
            return $logModel->tableDataAdmin($request);
        }
        return  View::fetch();
    }

    public function showInfo()
    {
        $id     = input('get.id');
        $list  = Db::name('api_serve_log')->where(['id' => $id])->find();
        View::assign([
            'token'         => $list['token'],
            'card_token'    => $list['card_token'],
            'param_request' => $list['param_request'],
            'param_response'=> $list['param_response'],
            'message'       => $list['message']
        ]);
        View::layout(false);
        return [
            'status'    => 1,
            'datas'     => View::fetch()
        ];
    }
}
